package com.csust.travel.controller;


import com.csust.travel.entity.ResBean;
import com.csust.travel.entity.Statistics;
import com.csust.travel.mapper.NewUsersMapper;
import com.csust.travel.mapper.StatisticsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
@RequestMapping("/statistics")
public class StatisticsController {
    @Autowired
    StatisticsMapper statisticsMapper;

    @Autowired
    NewUsersMapper newUsersMapper;

    @RequestMapping("/info")
    public ResBean getInfo(Integer user_id) {
        Statistics statistics =new Statistics();
        statistics.setBought(statisticsMapper.getBought(user_id));
        statistics.setSold(statisticsMapper.getSold(user_id));
        statistics.setComments(statisticsMapper.getComments(user_id));
        statistics.setFavorites(statisticsMapper.getFavorites(user_id));
        statistics.setPublished(statisticsMapper.getPublished(user_id));
        statistics.setTotalBooks(newUsersMapper.getTotalBook(user_id));
        statistics.setHasPublish(statisticsMapper.getHasPublished(user_id));
        statistics.setReviewing(statisticsMapper.getReviewing(user_id));
        return new ResBean(true, "成功", statistics);
    }

}
